# Euler Problem 3
# What is the largest prime factor of the number 600851475143?

import math
#################################
cycles = 50000
cycles = 1
import time
c1 = time.clock()
for x in xrange(0xFFFFF): pass
for i in range(cycles):
    answer = 0
#################################
### program calculation start ###
#################################

    #Takes 2.91 ms (50000 iterations)
    bignumber = 600851475143

    #bigsqrt = floor(sqrt(bignumber))
    #why does above not work?  below was calculated externally.
    #bigsqrt = 775146

    notdone = 2    
    while notdone:
        if bignumber % notdone == 0:
            print notdone
            bignumber = bignumber / notdone
        else:
            notdone += 1

        if notdone > math.sqrt(bignumber):
            notdone = 0

    answer = bignumber

#################################
###  program calculation end  ###
#################################
c2 = time.clock()
if cycles > 1: print "Time spent is %.2f ms" % ((c2-c1)*1000/cycles)
#################################
        
print 'The answer to Problem #3 is >>', answer, '<<'

        